package com.micro.modual.extension;

import com.micro.common.MicroConstant;
import com.micro.common.biz.GeneratorCodeUtil;
import com.micro.common.util.ObjectUtil;
import com.micro.common.util.SnowFlakeUtil;
import com.micro.modual.entity.SystemRole;
import com.micro.modual.model.bo.systemrole.SystemRoleBO;

import java.util.Date;

/**
 * <h1>系统角色表 延展类</h1>
 *
 * @author LevelCoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:23:26
 */
public class SystemRoleExtension {

    /**
     * <h2>转换: 系统角色表 新增</h2>
     *
     * @param systemRoleBO {@link SystemRoleBO} 系统角色表 新增/修改 请求对象
     * @return {@link SystemRole} 系统角色表
     */
    public static SystemRole converAddSystemRole(SystemRoleBO systemRoleBO) {
        SystemRole systemRole = new SystemRole();
        systemRole.setId(SnowFlakeUtil.getId());
        systemRole.setRoleCode(GeneratorCodeUtil.generatorSystemCode());
        systemRole.setCreateTime(new Date());
        systemRole.setRoleName(systemRoleBO.getRoleName());
        systemRole.setRoleDesc(systemRoleBO.getRoleDesc());
        systemRole.setRoleStatus(ObjectUtil.isNotEmpty(systemRoleBO.getRoleStatus()) ? systemRoleBO.getRoleStatus():(byte)2);
        return systemRole;
    }

    /**
     * <h2>转换: 系统角色表 修改</h2>
     *
     * @param systemRoleBO {@link SystemRoleBO} 系统角色表 新增/修改 请求对象
     * @return {@link SystemRole} 系统角色表
     */
    public static SystemRole converEditSystemRole(SystemRoleBO systemRoleBO) {
        SystemRole systemRole = new SystemRole();
        systemRole.setId(systemRoleBO.getId());
        systemRole.setRoleCode(systemRoleBO.getRoleCode());
        systemRole.setRoleName(systemRoleBO.getRoleName());
        systemRole.setRoleDesc(systemRoleBO.getRoleDesc());
        systemRole.setRoleStatus(systemRoleBO.getRoleStatus());
        systemRole.setCreateTime(systemRoleBO.getCreateTime());
        systemRole.setUpdateTime(systemRoleBO.getUpdateTime());
        return systemRole;
    }
}
